package com.demo2do.fms.entity.vehicle.source;

import java.util.Date;

import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;

import com.demo2do.core.utils.StringUtils;

/**
 *
 * @author Ark
 *
 */
@Entity
@Table(name = "FMS_VEHICLE_LOCK_RECORD")
public class VehicleSourceLockRecord {
    
    @Id
    @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "generator")
    @SequenceGenerator(name = "generator", sequenceName = "HIBERNATE_SEQUENCE", allocationSize = 1)
    private Long id;
    
    /** 对应车辆 */
    @ManyToOne(fetch = FetchType.LAZY, optional = false)
    private VehicleSource vehicleSource;
    
    /** 状态 */
    private LockStatus status;
    
    /** 记录描述 */
    private String description;
    
    /** 操作时间 */
    private Date createTime;
    
    /** 操作人 */
    private Long operator;
    
    /**
     * 
     */
    public VehicleSourceLockRecord() {
        
    }
    
    /**
     * 
     * @param vehicleSource
     * @param status
     * @param description
     * @param operator
     */
    public VehicleSourceLockRecord(VehicleSource vehicleSource, LockStatus status, String description, Long operator) {
        
    	this.vehicleSource = vehicleSource;
        this.status = status;
        
        if (vehicleSource.getLockType() != null) {
        	this.description = StringUtils.connect(description, " - ", vehicleSource.getLockType().getDescription());
        } else {
        	this.description = description;
        }
        
        this.createTime = new Date();
        this.operator = operator;
        
    }

    /**
     * @return the id
     */
    public Long getId() {
        return id;
    }

    /**
     * @return the vehicleSource
     */
    public VehicleSource getVehicleSource() {
        return vehicleSource;
    }

    /**
     * @return the status
     */
    public LockStatus getStatus() {
        return status;
    }
    
    /**
     * @return
     */
    public String getDescription() {
		return description;
	}

    /**
     * @return the createTime
     */
    public Date getCreateTime() {
        return createTime;
    }

    /**
     * @return the operator
     */
    public Long getOperator() {
        return operator;
    }

    /**
     * @param id the id to set
     */
    public void setId(Long id) {
        this.id = id;
    }

    /**
     * @param vehicleSource the vehicleSource to set
     */
    public void setVehicleSource(VehicleSource vehicleSource) {
        this.vehicleSource = vehicleSource;
    }

    /**
     * @param status the status to set
     */
    public void setStatus(LockStatus status) {
        this.status = status;
    }
    
    /**
     * @param description
     */
    public void setDescription(String description) {
		this.description = description;
	}

    /**
     * @param createTime the createTime to set
     */
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    /**
     * @param operator the operator to set
     */
    public void setOperator(Long operator) {
        this.operator = operator;
    }

}
